package com.dzx.awt;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author dzx
 * @ClassName:
 * @Description:
 * @date 2019年07月22日 09:25:26
 */
public class DialogDemo {
    private Frame f;
    private Button b;
    private Label l;
    private TextField tf;
    private TextArea ta;
    private Dialog d;

    public DialogDemo() {
        init();
    }

    public void init() {
        f = new Frame("test");
        f.setBounds(300, 100, 600, 500);
        f.setLayout(new FlowLayout());

        b = new Button("test button");
        l = new Label("test label");
        tf = new TextField("test TextField");
        ta = new TextArea("test TextArea");

        d = new Dialog(f, "test dialog", true);
        d.setBounds(300, 400, 200, 100);
        d.setLayout(new FlowLayout());

        f.add(l);
        f.add(tf);
        f.add(ta);
        f.add(b);
        myEvent();

        f.setVisible(true);

    }

    private void myEvent() {
        b.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                d.setVisible(true);
            }
        });
    }

    public static void main(String[] args) throws InterruptedException {
        new DialogDemo();
        Thread.sleep(10000);
        System.exit(1);
    }
}
